package com.vivien.example.springbootdemo.controller;

import com.vivien.example.springbootdemo.pojo.Products;
import com.vivien.example.springbootdemo.service.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/products")
public class ProductController {

    @Autowired
    private ProductsService productService;
    @GetMapping
    public List<Products> getAllProducts() {
        //return productService.list();
        List<Products> products = productService.list();
        // 打印数据到控制台
        System.out.println("Retrieved Products: " + products);
        return products;
    }

}
